home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / limitt_1 / frmmain.frm next >
Text File  |  1999-08-27  |  5KB  |  182 lines

  1. VERSION 5.00
  2. Begin VB.Form lblRGBDemo 
  3.    Caption         =   "RGBDemo"
  4.    ClientHeight    =   3780
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5880
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   252
  10.    ScaleMode       =   3  'Pixel
  11.    ScaleWidth      =   392
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.HScrollBar hscRGB 
  14.       Height          =   255
  15.       Index           =   2
  16.       Left            =   600
  17.       Max             =   255
  18.       TabIndex        =   6
  19.       Top             =   3480
  20.       Width           =   2295
  21.    End
  22.    Begin VB.HScrollBar hscRGB 
  23.       Height          =   255
  24.       Index           =   1
  25.       Left            =   600
  26.       Max             =   255
  27.       TabIndex        =   5
  28.       Top             =   3120
  29.       Width           =   2295
  30.    End
  31.    Begin VB.HScrollBar hscRGB 
  32.       Height          =   255
  33.       Index           =   0
  34.       Left            =   600
  35.       Max             =   255
  36.       TabIndex        =   4
  37.       Top             =   2760
  38.       Width           =   2295
  39.    End
  40.    Begin VB.PictureBox picColors 
  41.       AutoSize        =   -1  'True
  42.       Height          =   2745
  43.       Left            =   0
  44.       Picture         =   "frmMain.frx":0000
  45.       ScaleHeight     =   179
  46.       ScaleMode       =   3  'Pixel
  47.       ScaleWidth      =   382
  48.       TabIndex        =   0
  49.       Top             =   0
  50.       Width           =   5790
  51.    End
  52.    Begin VB.Label lblInfo 
  53.       Caption         =   "Move your mouse over the picture above and see what happens..."
  54.       Height          =   735
  55.       Left            =   3720
  56.       TabIndex        =   10
  57.       Top             =   2880
  58.       Width           =   1935
  59.    End
  60.    Begin VB.Shape Shape1 
  61.       Height          =   975
  62.       Left            =   3600
  63.       Top             =   2760
  64.       Width           =   2175
  65.    End
  66.    Begin VB.Label lblRGB 
  67.       Alignment       =   2  'Center
  68.       BorderStyle     =   1  'Fixed Single
  69.       Caption         =   "0"
  70.       Height          =   255
  71.       Index           =   2
  72.       Left            =   3000
  73.       TabIndex        =   9
  74.       Top             =   3480
  75.       Width           =   540
  76.    End
  77.    Begin VB.Label lblRGB 
  78.       Alignment       =   2  'Center
  79.       BorderStyle     =   1  'Fixed Single
  80.       Caption         =   "0"
  81.       Height          =   255
  82.       Index           =   1
  83.       Left            =   3000
  84.       TabIndex        =   8
  85.       Top             =   3120
  86.       Width           =   540
  87.    End
  88.    Begin VB.Label lblRGB 
  89.       Alignment       =   2  'Center
  90.       BorderStyle     =   1  'Fixed Single
  91.       Caption         =   "0"
  92.       Height          =   255
  93.       Index           =   0
  94.       Left            =   3000
  95.       TabIndex        =   7
  96.       Top             =   2760
  97.       Width           =   540
  98.    End
  99.    Begin VB.Label lblRGBDemo 
  100.       AutoSize        =   -1  'True
  101.       Caption         =   "Blue:"
  102.       Height          =   195
  103.       Index           =   2
  104.       Left            =   0
  105.       TabIndex        =   3
  106.       Top             =   3480
  107.       Width           =   360
  108.    End
  109.    Begin VB.Label lblRGBDemo 
  110.       AutoSize        =   -1  'True
  111.       Caption         =   "Green:"
  112.       Height          =   195
  113.       Index           =   1
  114.       Left            =   0
  115.       TabIndex        =   2
  116.       Top             =   3120
  117.       Width           =   480
  118.    End
  119.    Begin VB.Label lblRGBDemo 
  120.       AutoSize        =   -1  'True
  121.       Caption         =   "Red:"
  122.       Height          =   195
  123.       Index           =   0
  124.       Left            =   0
  125.       TabIndex        =   1
  126.       Top             =   2760
  127.       Width           =   345
  128.    End
  129. End
  130. Attribute VB_Name = "lblRGBDemo"
  131. Attribute VB_GlobalNameSpace = False
  132. Attribute VB_Creatable = False
  133. Attribute VB_PredeclaredId = True
  134. Attribute VB_Exposed = False
  135. 'Program : RGBDemo
  136. 'Author  : Yvo van Dillen
  137. 'Info    :
  138. '           Visual basic has the function :
  139. '           long = RGB(r,g,b)
  140. '           But how can you translate it back ?
  141. '           ( RGB(r,g,b) = long )
  142. '
  143. '          For any questions or other code
  144. '          mail to : yvo23@hotmail.com
  145.  
  146.  
  147. Private Sub hscRGB_Change(Index As Integer)
  148.     
  149.     'if one of the horizontal scroll-bars
  150.     'changes then update the value too. (behind the scrollbars)
  151.     
  152.     lblRGB(Index).Caption = Val(hscRGB(Index).Value)
  153.  
  154. End Sub
  155.  
  156. Private Sub picColors_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  157.     
  158.     'define variables
  159.     
  160.     Dim red As Integer
  161.     Dim green As Integer
  162.     Dim blue As Integer
  163.     Dim color As Long
  164.     
  165.     'grab the color from the picture (long)
  166.     
  167.     color = picColors.Point(X, Y)
  168.     
  169.     'This is the function that does it...
  170.     'You must give :
  171.     'A color ( and 3 RGB variables)
  172.     'GetRgb stores the red ,green and blue values
  173.     'in the give variables...
  174.     GetRgb color, red, green, blue
  175.     
  176.     'Update the scrollbars
  177.     hscRGB(0).Value = red
  178.     hscRGB(1).Value = green
  179.     hscRGB(2).Value = blue
  180.     
  181. End Sub
  182.